﻿
using RayDen.RayEngine.Core;
using RayDen.RayEngine.Core.Devices;
using RayDen.RayEngine.Core.Interface;
using RayDen.RayEngine.Core.Threads;
using RayDen.RayEngine.Managers;

namespace RayDen.RayEngine {
    public abstract class BaseRenderingEngine
    {

        public bool LowLatencySampling;
        
        public virtual int MaxThreadCount
        {
            get { return 8; }
        }

        public virtual int MaxBufferPerThread
        {
            get { return GlobalConfiguration.Instance.Get("Engine.PathIntegratorsPerThread", 4); }
        }

        protected BaseRenderingEngine(RayEngineScene scene) {
            LowLatencySampling = true;
            RenderThread.DeviceRenderBufferCount = this.MaxBufferPerThread;
        }

        public abstract RenderThread CreateRenderThread(int threadIndex, IntersectionEngine intersectionDevice, RayEngineScene scene, IImageFilm film, IFrameManager manager, SamplingContext samplingContext);
        public abstract ISampler CreateSampler(int width, int height, int maxPathDepth, int threadIndex, int screenStartLine, int windowHeight);
        public abstract Core.Interface.IImageFilm CreateFilm(int width, int height);

        public virtual string GetEngineStats()
        {
            return string.Empty;
        }

        public virtual bool PreprocessRequired 
        {
            get { return false; }
        }

        public virtual void Preprocess(RayEngineScene scene, IntersectionEngine ie)
        {
            
        }
    }
}
